P.O. Box 5308,Berkeley, CA 94705-0308; (415) 839-8958
Getting Started with GaussFitter (version 1.0):
GaussFitter is shareware based on the CurveFit™ package developed by Berkeley Scientific Associates (see MacWeek, 4/30/91). If you like it and use it often, please send $5 to the above address to support inexpensive technical software for future generations. Gaussfitter may be freely distributed but not modified. Please keep the sample data file & this Read Me file with it as you pass it along.
Briefly (!), GaussFitter can read TEXT files of numbers, display or graph the data, fit the data using a least-squares regression curve-fitting algorithm to a Gaussian function, redisplay the graph with the fitted curve (in red),display the parameters which are generated during the curve-fitting routine, and save the results of the fit in TEXT file(s).
The file called "GF sample data" contains some sample data (a 200 pt. Gaussian) with which you may practice using GaussFitter. However, before we get to the nitty-gritty stuff, some words of wisdom to guide you are in order.
The following is a brief overview (I) of using Gaussfitter, with a more detailed set of instructions behind it (II).
I) Gaussfitter quick & easy:
Read in any tab-delimited text file of numbers (names in the 1st row are USUALLY OK) up to 9 columns by 10,000 rows. Configure the desired Y vs. X set-up using the "configure graph" under the "Window" menu. (Pretty subtle,eh!) The data in our sample file initially will be plotted as a straight line, since GaussFitter will always plot the first column it can read versus "Record#". We want to plot "Y-data" vs. "X-data" for this example. Do it, select the "Fit" menu for a Gaussian (the only choice in THIS shareware application) and you're off to our standard "CurveFitz™" dialogue box. "Auto-guess" and "GO" for a quick convergence. The fit result can be viewed in the "Fit" window selected under the "Window" menu by "Bringing it to the front" (or use "Command-F"). It's just that simple!
II) Gaussfitter REDUX:
Data file particulars:
All data files must be of type TEXT (easily generated by most word processors as a special menu item (e.g., Save As Text...) or as part of the Save As... dialogue box). Data must exist as one or more columns of numbers.
Each column should be separated by a tab. One line of tab-delimited (i.e., separated by a tab) non-numerical column labels may precede the data. A maximum of nine columns of data may be read in at any one time. GaussFitter supplies an extra column of data called "Record#", which is just the running count of the number of data records. Columns may contain a maximum of 10,000 records.
Output file particulars:
Two different TEXT files may be generated from each successful curve fit. The Fit Data file, (which we default to be named with the suffix ".FIT"), contains three columns of numbers: the X and Y data columns from which the fit was generated (with appropriate labels), and a "Fit" column, which is the value of the gaussian function (plus a baseline) based on the parameters generated during the fit algorithm. The Fit Report (with suffix ".REP", get it!?) is a TEXT file containing only the equation for the gaussian function used in the fit routine and the values of the fitted parameters (intensity, gaussian center of mass, etc...) and results: the Chi-squared statistic. The variance in the parameters is based on an error of unity in the Y data. (To a good approximation, the actual variance in the parameters may be obtained by multiplying the known error in the Y data by the errors reported in the ".REP" file.)
A more complete TUTORIAL with the data file "GF sample data".
(You may want to run under Multifinder during this, and click back and forth between these instructions and GaussFitter).
Let's fit our sample data again. First, open the application and the file called "GF sample data" (you may have to "UnStuff" this file if you haven't already before opening it–– if you got this off a BBS). The data should now appear in two windows -- a Text window and a Graph window. The number of records and number of columns appear in the Text window at the top. (You may have to click in the Text window to see all of it.) The rest of the Text window shows the "Record#" column, and two columns labeled "X data" and "Y data", respectively. The columns show fifteen records each, followed by some dots to let us know that the file opened consists of more records than actually are shown. The utility of the Text window is that it displays just enough of each file so that the user can identify each column if he/she has not labeled it in the TEXT file. Also, two column labels have rectangles around them, showing which are being considered the X (open rectangle) and Y (filled rectangle) data columns.
By clicking back on the Graph window, the user can see the name of the file opened, plus a graph of the designated Y versus X data. The limits of the graph are set by the extremes in the data. This data should look like a nice straight line --clearly not a gaussian!! But, by glancing back to the Text window, we see we are plotting the column "X data" versus "Record#" (recall the filled and open rectangles). GaussFitter will always plot the first column it reads in versus "Record#" any time a new file is opened. In order to plot (and fit!) the "Y data" versus "X data" one must choose "Configure Graph" under the "Window" menu (or type Command-K). A dialogue box should now come up which allows the user to toggle radio buttons on and off in order to select a Y-axis (left hand column), a X-axis (middle), and a column of errors corresponding to errors in the Y-axis (you may choose an error column, but GaussFitter version 1.0 ignores the error column in the fit). Click the radio buttons beside the labels "Y data" and "X data" in the left two columns, respectively, and hit OK. The new graph window should show the proper columns plotted (X vs. Record # would also be a Gaussian).
To fit these data now, go to the Fit menu and select "Gaussian". A large dialogue box will come up, showing the data in a window to the upper right. The equation which is to be fitted to these data is shown at the top, and defines the parameters a1, a2, etc... which will be results of the fit. As with all (non-linear) fitting routines, we need to make a good initial guess of the parameters in order to expect convergence. Do so now by hitting the "Auto Guess" button (Command-A) located under the displayed data. The resulting curve drawn in the display window is usually a very good starting point for the routine. Notice that the parameters a1 through a5 (a6 and up are not used in GaussFitter) have been updated to reflect the values supplied by the auto-guessing exercise.
Before proceeding, let's illustrate some other functions in the fit dialogue box. Double click on the number next to the label "a4 =". Now type a "1.0" (no quotation marks!). Hit the button marked "Show Fit". Immediately, the displayed curve is updated to reflect the change in the parameter, a4. This change in baseline slope has shifted the starting curve away from the data by a significant amount. Hitting "Auto Guess" will restore the original guess. "Show Fit" will always use the current values of the parameters which are displayed next to their labels and calculate and display the resulting curve.
Another useful feature of the fit dialogue box is the "Get Old Data" button (Command-D), which allows the user to bring old sets of parameters
from previous curve fits (toggling between up to nine sets), and attempt to use them for comparison or as starting values. We have saved two such data sets with this application -- (you might have already saved some data sets yourself). By hitting "Get Old Data" you can view the resulting curves. The two stored sets show a Gaussian with either the center of mass or the width slightly off. We could manually enter a better guess for a1,etc., at this point and then hit "Show Fit", or we could simply hit "Auto Guess" again. Notice that a number appears next to the "Get Old Data" button when it is struck repeatedly: this tells the user which data set is currently displayed. When a curve fit has been successful, the new parameters from the successful fit will be saved automatically by the application and will be available through the "Get Old Data" button in future curve fitting attempts.
A brief summary of the other features of the fitting box follows:
GO -- hitting this button starts the curve fitting routine utilizing the
displayed initial parameters as starting guesses.
Simulate -- this button takes the current parameters and sends them
and the data based on them back to the main graph window menu; no fitting
is performed. The internal record of saved parameters is not updated.
Done-- similar to SIMULATE, except the internal record of parameters available through "Get Old Data" is updated to include the current set.
Cancel -- cancels any curve fitting; saves no internal records; returns to main menu.
Erase Old Data-- This button, when hit twice, will erase the internal record of saved parameter sets.
Hold?= check boxes -- click in these boxes to freeze a particular parameter at its current value during all curve fitting iterations.
Sig. Figs -- a field to allow the user to adjust how many digits are DISPLAYED. GaussFitter does all calculations accurate to sixteen digits regardless of the value in the Sig. Figs. box.
Tolerance -- a measure of the "pickiness" of the fit for convergence;
the higher the tolerance, the smaller the changes in the chi-squared value that GaussFitter will deem significant.
Max. Iter. -- the maximum number of iterations that GaussFitter will go through before giving up, if it doesn't converge.
Stepsize -- this is a measure of the amount that GaussFitter will adjust each parameter between each iteration in order to "zero in" on the best fit. Rarely does the user need to change this.
Y Error -- strictly speaking, this is the standard deviation of the Y data, which is assumed to be constant. "One" is the default.
Display Every ___ Iterations -- the frequency with which the screen is updated during fitting; for instance, if the value here is three, the screen will be updated after every third iteration.
Scientific -- clicking this check box causes the numbers to be printed in scientific notation (a bug in version 1.0 requires that this box be checked if the numbers are to be read during fitting).
Let's get back to our curve fitting. When you have decided on a suitable
starting parameter set, hit GO. The curve fitting will immediately
commence, and the parameters and graph will be updated at the end of
each iteration. You can stop the iterations by hitting "Command-PERIOD", and reenter values if you aren't satisfied with the progress toward convergence. Otherwise, the chi-squared value will eventually stop changing, and GaussFitter will pass back to the main menu section, where the curve fit will be plotted. A new window will appear, titled "Fit", and the newly generated fit information will be shown. You can bring any window in GaussFitter to the front by clicking on that window, or selecting the name of the window under "Bring to Front" under the "Windows" menu.
To save the "X data", "Y data" and the values of the fit corresponding to the parameters just calculated, choose "Save Fit Data" under the "File"
menu. To save the information in the "Fit" window, choose "Save Fit Report"
under the "File" menu. Note that the suffixes ".FIT" and ".REP" are the suggested defaults for these files.
Luckily, the user is not restricted to using our supplied sample data (!).
Try opening a TEXT file of your own, subject to the restrictions on input
files listed above, and fit it to your heart's delight. The TEXT output files
are ideal for importing into a number of spreadsheets and graphing programs for presentation and plotting. Questions about GaussFitter and other data analysis and curve fitting software can be directed to Berkeley Scientific Associates at (415) 839-8958, or the address shown above.